
<template>
  <div class="wdxj_box">
    <headercom></headercom>

    <div class="bcg">
      <div class="hedlist">
        <div class="headbtn">
          <a-button type="primary" @click="fbxj">发布询价</a-button>
        </div>
        <div class="head_search">
          <div class="sele">
            <a-input placeholder="请输入型号或品牌" v-model="xlpp" @change="xlchange" style="width: 200px" />
            <a-icon type="search" class="search" />
          </div>
        </div>
      </div>
      <div class="wdxj">
        <div class="hydj" v-if="$store.state.tjwz">
          <fbxjym class="hydj_xgym"></fbxjym>
        </div>
        <a-table :columns="columns" :dataSource="data">
          <template slot="sfgq" slot-scope="text,record,index">
            <span>
              <a-tag v-if="text =='报价中'" color="red">{{text}}</a-tag>
              <a-tag v-if="text =='已过期'" color="#ccc">{{text}}</a-tag>
            </span>
          </template>

          <tr slot="expandedRowRender" slot-scope="record">
            <!-- <span class="xj">
              <span class="spantit">本询价发往：</span>
              {{record.dwmc}}&nbsp;&nbsp;{{record.phone}}&nbsp;&nbsp;{{record.lxr}}
            </span>-->
            <span class="xj">
              <span class="spantit">备注：</span>
              {{record.mxbz}}
            </span>
          </tr>
          <template slot="sl" slot-scope="text,record">
            <span>
              <span style="color:red">{{record.sl}}</span>
              {{record.jldw}}
            </span>
          </template>
          <template slot="name" slot-scope="text">
            <a href="javascript:;">{{text}}</a>
          </template>
          <template
            slot="bxjfw"
            slot-scope="text,record"
          >{{record.dwmc}}&nbsp;&nbsp;{{record.phone}}&nbsp;&nbsp;{{record.lxr}}</template>
          <template slot="sfgq" slot-scope="text,record,index">
            <span>
              <a-tag v-if="text =='报价中'" color="red">{{text}}</a-tag>
              <a-tag v-if="text =='已过期'" color="#ccc">{{text}}</a-tag>
            </span>
          </template>
          <template slot="djzt" slot-scope="text,record,index">
            <span>
              <a-tag v-if="text =='全公开'" color="blue">{{text}}</a-tag>
              <a-tag v-if="text =='私有询价'" color="red">{{text}}</a-tag>
            </span>
          </template>
          <template slot="operation" slot-scope="text, record, index">
            <a-popconfirm
              :disabled="record.bjs>0?true:false"
              title="确认删除吗?"
              @confirm="() => onDelete(record,record.key)"
            >
              <a class="del" href="javascript:;">删除</a>
            </a-popconfirm>

            <a-badge :showZero="true" class="csbj" :count="record.bjs" v-if="record.bjs>0">
              <a
                href="#"
                style="margin-right:17px;"
                @click="()=>csbj(record,record.key)"
                class="head-example"
              >查报价</a>
            </a-badge>
            <a
              v-else
              href="#"
              style="margin-right:17px;"
              @click="()=>csbj(record,record.key)"
              class="head-example"
            >查报价</a>
          </template>
        </a-table>
        <div class="gl_tjwz" v-if="$store.state.bjlstk">
          <div class="gl_tjym bjtk">
            <div class="bjtk_list">
              <div class="head">
                <span></span>
                <a-button class="editable-add-btn" @click="close">
                  <a-icon type="close" />
                </a-button>
              </div>
              <a-table :pagination="pagination" :dataSource="dataSource" :columns="columnstk"></a-table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import headercom from "../header-comm/header.vue";
import fbxjym from "../fbxj/fbxjym.vue";

const columns = [
  {
    title: "型号 ",
    dataIndex: "gg"
  },
  {
    title: "品牌",
    dataIndex: "pp"
  },
  {
    title: "询价日期 ",
    dataIndex: "xjrq"
  },
  {
    title: "要求货期 ",
    dataIndex: "yqdhq"
  },
  {
    title: "需求数量",
    dataIndex: "sl",
    scopedSlots: { customRender: "sl" }
  },
  {
    title: "本询价发往 ",
    dataIndex: "bxjfw",
    scopedSlots: { customRender: "bxjfw" }
  },
  {
    title: "类型",
    dataIndex: "djzt",
    scopedSlots: { customRender: "djzt" }
  },
  {
    title: "状态 ",
    dataIndex: "sfgq",
    scopedSlots: { customRender: "sfgq" }
  },
  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" }
  }
];
const data = [];
import qs from "qs";
export default {
  data() {
    return {
      data,
      columns,
      dataSource: [],
      count: 2,
      columnstk: [
        {
          title: "报价型号",
          dataIndex: "gg",
          scopedSlots: { customRender: "gg" }
        },
        {
          title: "品牌",
          dataIndex: "pp"
        },
        {
          title: "报价公司",
          dataIndex: "bjgsmc"
        },
        {
          title: "报价联系人",
          dataIndex: "bjlxr"
        },
        {
          title: "手机",
          dataIndex: "bjlxrdh"
        },
        {
          title: "可供数量",
          dataIndex: "kgsl"
        },
        {
          title: "价格",
          dataIndex: "hsdj"
        },
        {
          title: "备注",
          dataIndex: "bjbz"
        }
      ],
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0
      },
      xlpp: ""
    };
  },
  methods: {
    xlchange(e) {
      this.xlpp = e.target.value;
      this.getwdxjlist(this.xlpp);
    },

    //查看报价
    csbj(value) {
      this.$store.state.bjlstk = true;
      this.axios
        .post(
          "xunjia/XunBaojiaList.php",
          qs.stringify({
            phone: this.$store.state.bbl_phone,
            xjxh: value.xjdbh
          })
        )
        .then(res => {
          if (res.data.code == 303) {
            this.dataSource = res.data.result;
            for (var i = 0; i < res.data.result.length; i++) {
              this.dataSource[i].key = i;
            }
          } else {
            this.dataSource = [];
          }
        });
    },

    //发布询价
    fbxj() {
      this.$store.state.tjwz = true;
    },
    close() {
      this.$store.state.bjlstk = false;
      this.$store.state.tjwz = false;
    },
    //获取列表
    getwdxjlist(ggpp) {
      this.axios
        .post(
          "xunjia/MyXunjiaList.php",
          qs.stringify({
            page: this.pagination.current,
            pageSize: this.pagination.defaultPageSize,
            phone: this.$store.state.bbl_phone,
            sqdwid: this.$store.state.bbl_sqdwid,
            ggpp: ggpp
          })
        )
        .then(res => {
          if (res.data.code == 303) {
            this.data = res.data.result.data;
            for (var i = 0; i < res.data.result.data.length; i++) {
              this.data[i].key = i;
              this.data[i].sfgq = res.data.result.data[i].sfgq.trim();
              this.data[i].djzt = res.data.result.data[i].djzt.trim();
            }
          } else {
            this.data = [];
          }
        });
    },
    //删除列表
    onDelete(value, key) {
      const dataSource = [...this.data];
      this.data = dataSource.filter(item => item.key !== key);
      this.axios
        .post(
          "xunjia/MyXunjiaListDelete.php",
          qs.stringify({
            id_num: value.id_num
          })
        )
        .then(res => {
          if (res.data.code == 303) {
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg,
              duration: 1.5
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg,
              duration: 1.5
            });
          }
        });
    }
  },
  components: {
    headercom,
    fbxjym
  },
  created() {
    this.getwdxjlist();
  }
};
</script>

<style lang='less' >
th.column-money,
td.column-money {
  text-align: right !important;
}

.wdxj_box {
  width: 100%;
  .hedlist {
    position: relative;
    top: 65px;
    width: 98%!important;
    left: 1%;
    height: 60px;
    background-color: #fff;
    text-align: left;
    padding: 0px 20px;
    display: flex;
    justify-content: space-between;
    z-index: 99;
    .head_search {
      .sele {
        position: relative;
        display: inline-block;
        margin: 0 10px;
        i {
          position: absolute;
          top: 22px;
          right: 8px;
          font-size: 16px;
        }
      }
    }
  }
  .wdxj {
    overflow: hidden;

    position: absolute;
    background-color: #fff;
    width: 98%;
    top: 140px;
    left: 1%;
    border: 1px solid #ccc;
    // box-shadow: 0px 0px 7px #ccc;
    .xj {
      margin: 0 20px 0 10px;
      .spantit {
        font-weight: bold;
        font-size: 15px;
      }
    }
    .hydj {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      background: rgba(0, 0, 0, 0.5);
      z-index: 999;
      height: 930px;
      .hydj_xgym {
        position: absolute;
        width: 80%;
        left: 50%;
        transform: translateX(-50%);
      }
    }
  }
  .gl_tjwz {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999999;
    height: 930px;
    .gl_tjym {
      position: absolute;
      width: 80%;
      left: 50%;
      transform: translateX(-50%);
    }
  }
  .csbj {
    .ant-scroll-number {
      right: 7px !important;
    }
  }
}

.bjtk {
  position: absolute;
  z-index: 9999;
  width: 90%;
  height: auto;
  background-color: #fff;
  text-align: left;
  padding: 20px;
  top: 77px;
  left: 152px;
  .bjtk_list {
    .head {
      display: flex;
      justify-content: space-between;
    }
    .editable-cell {
      position: relative;
    }

    .editable-cell-input-wrapper,
    .editable-cell-text-wrapper {
      padding-right: 24px;
    }

    .editable-cell-text-wrapper {
      padding: 5px 24px 5px 5px;
    }

    .editable-cell-icon,
    .editable-cell-icon-check {
      position: absolute;
      right: 0;
      width: 20px;
      cursor: pointer;
    }

    .editable-cell-icon {
      line-height: 18px;
      display: none;
    }

    .editable-cell-icon-check {
      line-height: 28px;
    }

    .editable-cell:hover .editable-cell-icon {
      display: inline-block;
    }

    .editable-cell-icon:hover,
    .editable-cell-icon-check:hover {
      color: #108ee9;
    }

    .editable-add-btn {
      margin-bottom: 8px;
    }
  }
}
</style>
